﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;

namespace Zxb.OneTimeWork
{
    public class RoomConfig
    {
        public string TypeID;
        public string TypeName;
        public string CasePictureTypeIDs;
        public string SimpleMark;

        private static object objLock = new object();
        private static List<RoomConfig> configList;
        public static List<RoomConfig> ConfigList
        {
            get
            {
                if (configList == null)
                {
                    lock (objLock)
                    {
                        if (configList == null)
                        {
                            configList = GetConfigList();
                        }
                    }
                }
                return configList;
            }
        }
        private static List<RoomConfig> GetConfigList()
        {
            List<RoomConfig> list = new List<RoomConfig>();
            list.Add(new RoomConfig() { TypeID = "1", TypeName = "客厅", CasePictureTypeIDs = "1,4", SimpleMark = "T" });
            list.Add(new RoomConfig() { TypeID = "2", TypeName = "卧室", CasePictureTypeIDs = "2,6,7,10", SimpleMark = "S" });
            list.Add(new RoomConfig() { TypeID = "3", TypeName = "厨房", CasePictureTypeIDs = "5", SimpleMark = "C" });
            list.Add(new RoomConfig() { TypeID = "4", TypeName = "卫生间", CasePictureTypeIDs = "3", SimpleMark = "W" });
            list.Add(new RoomConfig() { TypeID = "5", TypeName = "阳台", CasePictureTypeIDs = "9", SimpleMark = "Y" });

            return list;
        }
    }

    public class RoomData
    {
        public int RoomDataID;
        public string RoomDataTitle;
        public string RoomPic;
        public int RoomNum;
        public int HallNum;
        public int KitNum;
        public int ToiletNum;
        public int BalconyNum;
        public decimal Area;
        public long EstateID;
        public string RoomStyleXml;
        public int CityID;
        public string CityName;

        public RoomData(DataRow row)
        {
            RoomDataID = 0;
            int.TryParse(row["ID"].ToString(), out RoomDataID);
            RoomDataTitle = row["Title"].ToString();
            RoomPic = row["RoomPic"].ToString();
            RoomNum = 1;
            int.TryParse(row["RoomNum"].ToString(), out RoomNum);
            HallNum = 1;
            int.TryParse(row["HallNum"].ToString(), out HallNum);
            KitNum = 1;
            int.TryParse(row["KitchNum"].ToString(), out KitNum);
            ToiletNum = 1;
            int.TryParse(row["ToilitNum"].ToString(), out ToiletNum);
            BalconyNum = 1;
            int.TryParse(row["BalconyNum"].ToString(), out BalconyNum);
            Area = 0;
            decimal.TryParse(row["Area"].ToString(), out Area);
            Area = Area / 10000;

            EstateID = 0L;
            long.TryParse(row["EstateID"].ToString(), out EstateID);

            RoomStyleXml = row["RoomStyleXml"].ToString();

            CityID = 0;
            int.TryParse(row["CityID"].ToString(), out CityID);

            CityName = row["CityName"].ToString();
        }
    }

    public class RoomConstant
    {
        public static string[] Halls = new string[5] { "一厅", "二厅", "三厅", "四厅", "五厅" };
        public static string[] Rooms = new string[8] { "一居室", "二居室", "三居室", "四居室", "复式", "跃层", "别墅", "其它" };
        public static string[] Toilets = new string[4] { "一卫", "二卫", "三卫", "四卫" };
        public static string[] Styles = new string[8] { "现代简约", "田园风格", "中式古典", "西式古典", "欧美风情", "东南亚风格", "混合型风格", "日韩风格" };
    }
}
